﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Webshop20.Domain.Common;

namespace Webshop20.Domain.Stock.Core
{
    public class Good : Entity
    {
        public virtual string Hall { get; private set; }
        public virtual string Section { get; private set; }
        public virtual string Rack { get; private set; }
        public virtual string ProductCode { get; private set; }
        public virtual int ItemsInStock { get; private set; }
        public virtual int ItemsReserved { get; private set; }

        public Good()
        {}

        public Good(string productCode, int initialItemsInStock)
        {
            ProductCode = productCode;
            ItemsInStock = initialItemsInStock;
        }

        public virtual int TryReserveItem(int attemptedQuantity)
        {
            int possibleReservations ;
            if (ItemsInStock - attemptedQuantity > 0)
                possibleReservations = attemptedQuantity;
            else
                possibleReservations = attemptedQuantity - ItemsInStock;

            ItemsReserved += possibleReservations;
            
            return possibleReservations;
        }

        public virtual void ResolveReservation(int quantity)
        {
            throw new NotImplementedException();
        }

        public virtual void ChangeLocation(string newHall, string newSection, string newRack)
        {
            throw new NotImplementedException();
        }

        public virtual void AddItemsToStock(int quantity)
        {
            throw new NotImplementedException();           
        }

    }
}